package com.controller;

import com.entity.PostGreSqlTest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

/**
 * @ClassName PsSqlController
 * @Author lenovo
 * @Date 2024/1/19 11:55
 * @Version 1.0
 * @Description TODO
 **/
@Slf4j
@RestController
@RequestMapping("psSql")
public class PsSqlController {
    @Autowired
    @Qualifier("jdbc_pgsql")
    private JdbcTemplate jdbcTemplate;

    @RequestMapping(value = "/getUser")
    public Object get() {
        String sql = "select count(*) from test";
        return jdbcTemplate.queryForObject(sql, Long.class);
    }
    @RequestMapping(value = "/insert")
    public Object insert() {
        String sql = "insert into test (name,age) values (?,?)";
        jdbcTemplate.update(sql, "lenovo", 18);
        return "ok";
    }
}
